home *** CD-ROM | disk | FTP | other *** search
/ World of Video / World of Video.iso / datafiles / gfx_formats / gif / gif2.std < prev    next >
Text File  |  1995-02-13  |  43KB  |  1,268 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.                                G I F (tm)
  13.  
  14.                     Graphics Interchange Format (tm)
  15.  
  16.  
  17.  
  18.                            A standard for the
  19.                         storage and transmission
  20.                   of raster-based graphics information
  21.  
  22.  
  23.  
  24.  
  25.  
  26.                 * * * * PRELIMINARY REVIEW DRAFT * * * *
  27.  
  28.  
  29.  
  30.  
  31.                           Software Version 87a
  32.  
  33.                           Document Revision 1.0
  34.  
  35.                                 May 1988
  36.  
  37.  
  38.                 (c) 1987, 1988 by CompuServe Incorporated
  39.                            All rights reserved
  40.  
  41.  
  42.  
  43.         "GIF" and "Graphics Interchange Format" are trademarks of
  44.                         CompuServe Incorporated,
  45.                           an H&R Block Company
  46.  
  47.                        5000 Arlington Centre Blvd.
  48.                           Columbus, Ohio 43220
  49.                              (614) 457-8600
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  Disclaimer
  104.  
  105.  This document contains the latest information available at the time of
  106.  its creation.  However, CompuServe reserves the right to modify the
  107.  services described herein at any time, with or without written
  108.  notification.
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.                                        i
  134.  
  135.                                Table of Contents
  136.  
  137.  
  138.  Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .   ii
  139.  
  140.  1.0  Introduction to GIF  . . . . . . . . . . . . . . . . . . . . .    1
  141.  
  142.       1.1  Changes to GIF  . . . . . . . . . . . . . . . . . . . . .    2
  143.  
  144.       1.2  Availability of GIF . . . . . . . . . . . . . . . . . . .    3
  145.  
  146.       1.3  Naming Files which Contain GIF Data . . . . . . . . . . .    4
  147.  
  148.       1.4  GIF Development Area  . . . . . . . . . . . . . . . . . .    5
  149.  
  150.  2.0  Format of GIF Data . . . . . . . . . . . . . . . . . . . . . .    6
  151.  
  152.       2.1  Signature/Version Block . . . . . . . . . . . . . . . . .    8
  153.  
  154.       2.2  Logical Screen Descriptor Block . . . . . . . . . . . . .   10
  155.  
  156.       2.3  Global Color Map Block  . . . . . . . . . . . . . . . . .   14
  157.  
  158.       2.4  Extension Block . . . . . . . . . . . . . . . . . . . . .   16
  159.  
  160.            2.4.1  Comment Extension Block  . . . . . . . . . . . . .   18
  161.  
  162.            2.4.2  Image Control Extension Block  . . . . . . . . . .   20
  163.  
  164.       2.5  Image Descriptor Block  . . . . . . . . . . . . . . . . .   23
  165.  
  166.            2.5.1  Interlaced Image Processing  . . . . . . . . . . .   27
  167.  
  168.       2.6  Local Color Map Block . . . . . . . . . . . . . . . . . .   29
  169.  
  170.       2.7  Raster Data Block . . . . . . . . . . . . . . . . . . . .   30
  171.  
  172.       2.8  Terminator Block  . . . . . . . . . . . . . . . . . . . .   32
  173.  
  174.  3.0  Encoding and Decoding  . . . . . . . . . . . . . . . . . . . .   33
  175.  
  176.       3.1  Compressing and Expanding Pixel Data  . . . . . . . . . .   35
  177.  
  178.       3.2  Byte Packaging  . . . . . . . . . . . . . . . . . . . . .   37
  179.  
  180.       3.3  Display Rendering . . . . . . . . . . . . . . . . . . . .   38
  181.  
  182.  4.0  Transmitting and Displaying GIF Data . . . . . . . . . . . . .   39
  183.  
  184.       4.1  GIF Enquiry Escape Sequence and Response  . . . . . . . .   40
  185.  
  186.       4.2  GIF Invocation Escape Sequences . . . . . . . . . . . . .   45
  187.  
  188.       4.3  Terminating Display of an Image . . . . . . . . . . . . .   46
  189.  
  190.       4.4  User Interface to Decoders  . . . . . . . . . . . . . . .   47
  191.  
  192.  Appendix:  Compression and Expansion Algorithm  . . . . . . . . .    A-1
  193.  
  194.  
  195.  GIF                                                   Revision 1.0, 5/88
  196.  
  197.  
  198.  
  199.                                       ii
  200.  
  201.  Preface
  202.  ------------------------------------------------------------------------
  203.  ------------------------------------------------------------------------
  204.  
  205.  Objectives      The objectives of this document are to:
  206.  
  207.                    . describe the Graphics Interchange Format (GIF)
  208.  
  209.                    . describe encoding and decoding 
  210.  
  211.                    . provide guidelines for application programs which
  212.                      transmit and display GIF data
  213.  
  214.                  The document describes version 87a of GIF.
  215.  
  216.                  --------------------------------------------------------
  217.  
  218.  Intended        The intended audience of this document is graphics
  219.  audience        programmers who write application programs which use GIF
  220.                  data.
  221.  
  222.                  --------------------------------------------------------
  223.  
  224.  Organization    A table of contents is provided to aid in locating
  225.                  specific information within the document.
  226.  
  227.                  The document contains an introduction to GIF which is
  228.                  followed by detailed information about GIF.  This
  229.                  detailed information is divided into three sections:
  230.  
  231.                    . Format of GIF data
  232.  
  233.                    . Encoding and decoding
  234.  
  235.                    . Transmitting and displaying GIF data
  236.  
  237.                  The compression and expansion algorithm applied to pixel
  238.                  data is included in the Appendix at the end of the
  239.                  document.
  240.  
  241.                  --------------------------------------------------------
  242.  
  243.  Conventions     The following conventions are used in this document:
  244.  
  245.                    . all numbers are decimal unless otherwise indicated
  246.  
  247.                    . a hexadecimal number is immediately followed by a
  248.                      lowercase "h"
  249.  
  250.                      Examples:  0h, 2Ch, FFh, A014h
  251.  
  252.                  --------------------------------------------------------
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.                                                               (continued)
  260.  
  261.  GIF                                                   Revision 1.0, 5/88
  262.  
  263.  
  264.  
  265.                                       iii
  266.  
  267.  Preface, continued
  268.  ------------------------------------------------------------------------
  269.  ------------------------------------------------------------------------
  270.  
  271.  Conventions       . exponentiation is represented in the standard
  272.  (continued)         mathematical superscripted fashion
  273.                                                                  (n+1)
  274.                      Example:  2 to the (n+1) power is shown as 2
  275.  
  276.                    . bits within a byte are numbered from right to left,
  277.                      starting with 0; bit 0 is the least significant bit
  278.                      and bit 7 is the most significant bit
  279.  
  280.                    . American Standard Code for Information Interchange
  281.                      (ASCII) character codes are often listed in
  282.                      parentheses after special characters (for example,
  283.                      ^) and character sequences which must be entered
  284.                      exactly as shown; this is done, in part, to avoid
  285.                      confusion when the document is transmitted
  286.                      electronically and special characters in the
  287.                      resulting file do not appear as they did in the
  288.                      original document
  289.  
  290.                  --------------------------------------------------------
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  GIF                                                   Revision 1.0, 5/88
  328.  
  329.  
  330.  
  331.                                        1
  332.  
  333.  1.0  Introduction to GIF
  334.  ------------------------------------------------------------------------
  335.  ------------------------------------------------------------------------
  336.  
  337.  What is GIF?    GIF is the acronym for Graphics Interchange Format.  GIF
  338.                  is a format which is used to store and transmit raster-
  339.                  based color and monochrome images in an efficient,
  340.                  hardware-independent manner.
  341.  
  342.                  --------------------------------------------------------
  343.  
  344.  History of GIF  GIF was developed by CompuServe Incorporated to address
  345.                  the need for a general color image definition and to
  346.                  facilitate the exchange of images between dissimilar
  347.                  computer hardware.  
  348.  
  349.                  --------------------------------------------------------
  350.  
  351.  Features        To encourage its use in a wide variety of applications,
  352.                  an explicit design goal of GIF is to provide a flexible
  353.                  and comprehensive set of features.  These features
  354.                  include:
  355.  
  356.                    . arbitrary image dimensions up to 64K pixels
  357.  
  358.                    . as many as 256 colors in a given image
  359.  
  360.                    . image colors chosen from a palette of over 16
  361.                      million colors 
  362.  
  363.                    . hardware-independent format
  364.  
  365.                    . reduced file sizes by use of advanced data
  366.                      compression techniques
  367.  
  368.                    . efficient decoding method which allows online
  369.                      viewing of images via networks
  370.  
  371.                                    . hardware-independent format not as efficient as a
  372.                      hardware-specific format
  373.  
  374.                    . transmission of GIF data requires full 8-bit
  375.                      transmission capability
  376.  
  377.                    . follows raster-based, as opposed to object-based,
  378.                      graphics philosophy
  379.  
  380.                    . quality of image display subject to limitations of
  381.                      display hardware
  382.  
  383.                  --------------------------------------------------------
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  GIF                                                   Revision 1.0, 5/88
  390.  
  391.  
  392.  
  393.                                        2
  394.  
  395.  1.1  Changes to GIF
  396.  ------------------------------------------------------------------------
  397.  ------------------------------------------------------------------------
  398.  
  399.  Controlling     Changes to the GIF definition are under the control of
  400.  changes         CompuServe and will remain so until GIF is proposed or
  401.                  adopted as an official industry standard.  Changes are
  402.                  expected every 12-18 months to address the needs of the
  403.                  evolving graphics marketplace.
  404.  
  405.                  --------------------------------------------------------
  406.  
  407.  User            Users are discouraged from making ad hoc changes to the
  408.  enhancements    GIF definition, not only to avoid the "multiple-variant"
  409.                  syndrome other public domain computer standards suffer
  410.                  from, but also to keep in the spirit of machine and
  411.                  application independence central to the GIF effort.
  412.  
  413.                  --------------------------------------------------------
  414.  
  415.  Proposing       Users are encouraged to submit their proposals for
  416.  changes         changes to the GIF definition.  Each proposal should
  417.                  outline the change and the reasoning behind it. 
  418.                  Proposals may be submitted via U.S. mail to:
  419.  
  420.                       Manager of Graphics Technology
  421.                       CompuServe Incorporated
  422.                       5000 Arlington Centre Boulevard
  423.                       Columbus, Ohio  43220
  424.  
  425.                  Proposals may also be submitted in the GIF development
  426.                  area of the CompuServe Information Service (CIS) (see
  427.                  section 1.4, page 5).
  428.  
  429.                  --------------------------------------------------------
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  GIF                                                   Revision 1.0, 5/88
  456.  
  457.  
  458.  
  459.                                        3
  460.  
  461.  1.2  Availability of GIF
  462.  ------------------------------------------------------------------------
  463.  ------------------------------------------------------------------------
  464.  
  465.  Availability    GIF is available for use in any application program
  466.  of GIF          without royalties or licensing restrictions.  CompuServe
  467.                  does ask, however, that any such program include a
  468.                  trademark statement attributing ownership of GIF to
  469.                  CompuServe Incorporated.
  470.  
  471.                  --------------------------------------------------------
  472.  
  473.  Support for     GIF support is available in the GIF development area of
  474.  GIF             the CompuServe Information Service (CIS) (see section
  475.                  1.4, page 5).
  476.  
  477.                  --------------------------------------------------------
  478.  
  479.  
  480.  
  481.  
  482.  
  483.  
  484.  
  485.  
  486.  
  487.  
  488.  
  489.  
  490.  
  491.  
  492.  
  493.  
  494.  
  495.  
  496.  
  497.  
  498.  
  499.  
  500.  
  501.  
  502.  
  503.  
  504.  
  505.  
  506.  
  507.  
  508.  
  509.  
  510.  
  511.  
  512.  
  513.  
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  GIF                                                   Revision 1.0, 5/88
  522.  
  523.  
  524.  
  525.                                        4
  526.  
  527.  1.3  Naming Files which Contain GIF Data
  528.  ------------------------------------------------------------------------
  529.  ------------------------------------------------------------------------
  530.  
  531.  Overview        Guidelines for naming files which contain GIF data are
  532.                  provided in this section.  Use of these guidelines is
  533.                  suggested; however, their use is not necessary for
  534.                  conformance with the GIF standard.
  535.  
  536.                  --------------------------------------------------------
  537.  
  538.  In MS-DOS and   Use ".GIF" as the extension for a file which contains
  539.  similar         GIF data when in MS-DOS or a similar operating system.
  540.  operating
  541.  systems
  542.                  --------------------------------------------------------
  543.  
  544.  With the Apple  Classify a file which contains GIF data as type "GIFf"
  545.  Macintosh       when using software for the Apple Macintosh which reads
  546.                  or writes such files.  Doing this helps to prevent
  547.                  problems when using communications programs to transfer
  548.                  files.
  549.  
  550.                  No official GIF icon has been defined to represent files
  551.                  which contain GIF data.  Any icon used to represent such 
  552.                  files should include the characters "GIF".
  553.  
  554.                  --------------------------------------------------------
  555.  
  556.  With other      When naming files which contain GIF data, use a unique
  557.  operating       and consistent file identification within the structure
  558.  systems         of the local file identification conventions.
  559.  
  560.                  --------------------------------------------------------
  561.  
  562.  
  563.  
  564.  
  565.  
  566.  
  567.  
  568.  
  569.  
  570.  
  571.  
  572.  
  573.  
  574.  
  575.  
  576.  
  577.  
  578.  
  579.  
  580.  
  581.  
  582.  
  583.  
  584.  
  585.  
  586.  
  587.  GIF                                                   Revision 1.0, 5/88
  588.  
  589.  
  590.  
  591.                                        5
  592.  
  593.  1.4  GIF Development Area
  594.  ------------------------------------------------------------------------
  595.  ------------------------------------------------------------------------
  596.  
  597.  What is the     The GIF development area is an area within the
  598.  GIF             CompuServe Information Service (CIS) where CompuServe
  599.  development     provides GIF support and incentives for its use by
  600.  area?           independent software developers.  The GIF development
  601.                  area is located in the Pictures Support Forum.
  602.  
  603.                  --------------------------------------------------------
  604.  
  605.  Benefits of     Benefits of joining the GIF development area include:
  606.  joining the
  607.  area              . free access to the area
  608.  
  609.                    . access to GIF source code modules
  610.  
  611.                    . access to GIF utilities and working programs
  612.  
  613.                    . support from CompuServe associates
  614.  
  615.                    . support from other GIF developers
  616.  
  617.                    . periodic electronic conferences with CompuServe
  618.                      associates and other GIF developers
  619.  
  620.                  --------------------------------------------------------
  621.  
  622.  Requirements    Members of the GIF development area must:
  623.  
  624.                    . be CIS subscribers
  625.  
  626.                    . adhere to the published GIF standard
  627.  
  628.                    . include, in any application program developed using
  629.                      GIF, a trademark statement attributing ownership of
  630.                      GIF to CompuServe Incorporated 
  631.  
  632.                  --------------------------------------------------------
  633.  
  634.  How to join     To become a member of the GIF development area:
  635.  
  636.                   1.  Access the Pictures Support Forum (direct access
  637.                       may be obtained by typing the CIS command "GO
  638.                       PICS").
  639.  
  640.                   2.  Join the Pictures Support Forum by following the
  641.                       instructions provided in that forum.
  642.  
  643.                   3.  Enter library 1 of the Pictures Support Forum
  644.                       (General/Utilities).
  645.  
  646.                   4.  Read the file "DEVGIF.TXT" and follow its
  647.                       instructions for joining the GIF development area.
  648.  
  649.                  Once your application has been approved, access will be
  650.                  granted to the GIF development area.
  651.                  --------------------------------------------------------
  652.  
  653.  GIF                                                   Revision 1.0, 5/88
  654.  
  655.  
  656.  
  657.                                        6
  658.  
  659.  2.0  Format of GIF Data 
  660.  ------------------------------------------------------------------------
  661.  ------------------------------------------------------------------------
  662.  
  663.  Overview        On a display surface, an image is a rectangular array of
  664.                  pixels.  This pixel array may be stored in a file as a
  665.                  series of pixels.  GIF defines a format for storing
  666.                  pixels and the information needed to interpret and
  667.                  display the pixels.
  668.  
  669.                  A file may be comprised entirely of GIF data;
  670.                  conversely, GIF data may be one component of a much
  671.                  larger file.
  672.  
  673.                  --------------------------------------------------------
  674.  
  675.  Pixels          With GIF, an image is stored as a series of pixels. 
  676.                  These pixels serve as index values into a color map. 
  677.                  The color map defines the color assigned to each pixel.
  678.  
  679.                  Pixels are stored without any indication of position
  680.                  within the image. 
  681.  
  682.                  --------------------------------------------------------
  683.  
  684.  Color maps      A color map is a series of red, green, and blue
  685.                  intensity values that defines the individual colors
  686.                  which may appear in an image.  Pixels serve as index
  687.                  values into the color map.  
  688.  
  689.                  GIF data may include a global color map; this global
  690.                  map is used for each image when no local color map is
  691.                  associated with the image.  A local color map is a
  692.                  color map that is used for only one image.  When no
  693.                  global or local color map is present, pixels cannot be
  694.                  mapped to color definitions, and interpretation of
  695.                  pixels is indeterminate.
  696.  
  697.                  --------------------------------------------------------
  698.  
  699.  Format of GIF   GIF data is comprised of functional data blocks, some of
  700.  data            which may be repeated, others of which are optional. 
  701.                  These blocks are shown on the following page and are
  702.                  described in detail in the following sections.
  703.  
  704.                  --------------------------------------------------------
  705.  
  706.  
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.                                                               (continued)
  718.  
  719.  GIF                                                   Revision 1.0, 5/88
  720.  
  721.  
  722.  
  723.                                        7
  724.  
  725.  2.0  Format of GIF Data, continued
  726.  ------------------------------------------------------------------------
  727.  ------------------------------------------------------------------------
  728.  
  729.  Format of GIF                          GIF Data
  730.  data
  731.  (continued)     +---------------------------------+
  732.                  |     Signature/Version Block     |
  733.                  +---------------------------------+ -+
  734.                  | Logical Screen Descriptor Block |  | Logical Screen
  735.                  +---------------------------------+  | Block
  736.                  |Global Color Map Block (optional)|  |
  737.                  +---------------------------------+ -+
  738.                  |   Extension Block (optional)    | -- may be repeated
  739.                  +---------------------------------+ -+
  740.                  |     Image Descriptor Block      |  |
  741.                  +---------------------------------+  | Image Block;
  742.                  |Local Color Map Block (optional) |  | may be repeated
  743.                  +---------------------------------+  |
  744.                  |      Raster Data Block(s)       |  |
  745.                  +---------------------------------+ -+
  746.                  |   Extension Block (optional)    | -- may be repeated
  747.                  +---------------------------------+
  748.                  |        Terminator Block         |
  749.                  +---------------------------------+
  750.  
  751.                  --------------------------------------------------------
  752.  
  753.  Data types      Data type refers to the structure of a data segment and
  754.                  determines how that data segment is interpreted.  The
  755.                  data types used in GIF data are:
  756.  
  757.                  +---------+--------------------------------------------+
  758.                  |Data Type|                Description                 |
  759.                  +---------+--------------------------------------------+
  760.                  |byte     |8-bit unsigned value; may represent charac- |
  761.                  |         |ters or numeric values between 0 and 255    |
  762.                  +---------+--------------------------------------------+
  763.                  |field    |2 to 7 contiguous bits within a given byte; |
  764.                  |         |interpretation depends on the quantity      |
  765.                  |         |represented                                 |
  766.                  +---------+--------------------------------------------+
  767.                  |flag     |1-bit value which represents a logical true |
  768.                  |         |(1) or false (0)                            |
  769.                  +---------+--------------------------------------------+
  770.                  |integer  |16-bit unsigned integer value; always stored|
  771.                  |         |least significant byte first                |
  772.                  +---------+--------------------------------------------+
  773.  
  774.                  --------------------------------------------------------
  775.  
  776.  
  777.  
  778.  
  779.  
  780.  
  781.  
  782.  
  783.  
  784.  
  785.  GIF                                                   Revision 1.0, 5/88
  786.  
  787.  
  788.  
  789.                                        8
  790.  
  791.  2.1  Signature/Version Block
  792.  ------------------------------------------------------------------------
  793.  ------------------------------------------------------------------------
  794.  
  795.  Overview        The Signature/Version Block:
  796.  
  797.                    . identifies a block of data as GIF data
  798.  
  799.                    . indicates the version of GIF used to define the
  800.                      data
  801.  
  802.                  --------------------------------------------------------
  803.  
  804.  Use of the      Decoding software may use the Signature/Version Block to
  805.  Signature/      determine the version of GIF used to define the data.  
  806.  Version Block   This information may be needed by the decoding software
  807.                  to determine if it is able to process the data; if the
  808.                  decoding software was built from a version of GIF which
  809.                  is older than that used to define the data, the
  810.                  decoding software may not be able to adequately support
  811.                  features of the newer definition.
  812.  
  813.                  --------------------------------------------------------
  814.  
  815.  Existence       The Signature/Version Block is required.  It must be the
  816.                  first block in the GIF data.
  817.  
  818.                  --------------------------------------------------------
  819.  
  820.  Size            The Signature/Version Block is six bytes long.
  821.  
  822.                  --------------------------------------------------------
  823.  
  824.  Structure of    The structure of the Signature/Version Block is
  825.  the Signature/  illustrated below.
  826.  Version Block
  827.                                Bits
  828.  
  829.                    7   6   5   4   3   2   1   0    Byte #
  830.                  +---+---+---+---+---+---+---+---+
  831.                  |                               |    1
  832.                  +-                             -+
  833.                  |           Signature           |    2
  834.                  +-                             -+
  835.                  |                               |    3
  836.                  +-------------------------------+
  837.                  |                               |    4
  838.                  +-                             -+
  839.                  |            Version            |    5
  840.                  +-                             -+
  841.                  |                               |    6
  842.                  +-------------------------------+ 
  843.  
  844.                  --------------------------------------------------------
  845.  
  846.  
  847.  
  848.  
  849.                                                               (continued)
  850.  
  851.  GIF                                                   Revision 1.0, 5/88
  852.  
  853.  
  854.  
  855.                                        9
  856.  
  857.  2.1  Signature/Version Block, continued
  858.  ------------------------------------------------------------------------
  859.  ------------------------------------------------------------------------
  860.  
  861.  Structure of    where:
  862.  the
  863.  Signature/      +------------+-------+---------------------------------+
  864.  Version Block   |    Item    | Data  |           Description           |
  865.  (continued)     |            | Type  |                                 |
  866.                  +------------+-------+---------------------------------+
  867.                  |Signature   |bytes  |ASCII text characters "GIF"      |
  868.                  |            |       |(47h 49h 46h); identifies the    |
  869.                  |            |       |block as GIF data                |
  870.                  +------------+-------+---------------------------------+
  871.                  |Version     |bytes  |3-byte string of ASCII characters|
  872.                  |            |       |which identifies the version of  |
  873.                  |            |       |GIF used to define the data; the |
  874.                  |            |       |first two characters are the     |
  875.                  |            |       |year of the definition and the   |
  876.                  |            |       |last character is the lowercase  |
  877.                  |            |       |alphabetic version sequence      |
  878.                  |            |       |number; the current version      |
  879.                  |            |       |is 87a (38h 37h 61h)             |
  880.                  +------------+-------+---------------------------------+
  881.  
  882.                  --------------------------------------------------------
  883.  
  884.  
  885.  
  886.  
  887.  
  888.  
  889.  
  890.  
  891.  
  892.  
  893.  
  894.  
  895.  
  896.  
  897.  
  898.  
  899.  
  900.  
  901.  
  902.  
  903.  
  904.  
  905.  
  906.  
  907.  
  908.  
  909.  
  910.  
  911.  
  912.  
  913.  
  914.  
  915.  
  916.  
  917.  GIF                                                   Revision 1.0, 5/88
  918.  
  919.  
  920.  
  921.                                       10
  922.  
  923.  2.2  Logical Screen Descriptor Block
  924.  ------------------------------------------------------------------------
  925.  ------------------------------------------------------------------------
  926.  
  927.  Overview        The Logical Screen Descriptor Block:
  928.  
  929.                    . defines the logical screen
  930.  
  931.                    . provides information about the global color map
  932.  
  933.                    . provides information about image pixels
  934.  
  935.                    . specifies the background color
  936.  
  937.                    . specifies the pixel aspect ratio
  938.  
  939.                  --------------------------------------------------------
  940.  
  941.  What is the     The logical screen is the area required to contain the
  942.  logical         images in a block of GIF data.  The dimensions of the
  943.  screen?         logical screen are specified in the Logical Screen
  944.                  Descriptor Block.  
  945.  
  946.                  Note that the logical screen may be larger than the
  947.                  display surface.
  948.  
  949.                  --------------------------------------------------------
  950.  
  951.  What is pixel   Pixel aspect ratio is the ratio of a pixel's height as
  952.  aspect ratio?   compared to its width, and it serves as an indication of
  953.                  the pixel's shape.  A pixel aspect ratio of 1.0 defines
  954.                  a square pixel; a ratio of 2.0 defines a pixel which is
  955.                  twice as high as it is wide.
  956.  
  957.                  --------------------------------------------------------
  958.  
  959.  Existence       The Logical Screen Descriptor Block is required.  It
  960.                  must immediately follow the Signature/Version Block.
  961.  
  962.                  --------------------------------------------------------
  963.  
  964.  Size            The Logical Screen Descriptor Block is seven bytes long.
  965.  
  966.                  --------------------------------------------------------
  967.  
  968.  
  969.  
  970.  
  971.  
  972.  
  973.  
  974.  
  975.  
  976.  
  977.  
  978.  
  979.  
  980.  
  981.                                                               (continued)
  982.  
  983.  GIF                                                   Revision 1.0, 5/88
  984.  
  985.  
  986.  
  987.                                       11
  988.  
  989.  2.2  Logical Screen Descriptor Block, continued
  990.  ------------------------------------------------------------------------
  991.  ------------------------------------------------------------------------
  992.  
  993.  Structure of    The structure of the Logical Screen Descriptor Block is
  994.  the Logical     illustrated below.
  995.  Screen
  996.  Descriptor                    Bits
  997.  Block
  998.                    7   6   5   4   3   2   1   0    Byte #
  999.                  +---+---+---+---+---+---+---+---+
  1000.                  |                               |    1
  1001.                  +-        Screen Width         -+
  1002.                  |                               |    2
  1003.                  +-------------------------------+
  1004.                  |                               |    3
  1005.                  +-        Screen Height        -+
  1006.                  |                               |    4
  1007.                  +---+-----------+---+-----------+
  1008.                  |Map| Color Res |R1 |Pixel Size |    5
  1009.                  +---+-----------+---+-----------+
  1010.                  |    Background Color Index     |    6
  1011.                  +---+---------------------------+
  1012.                  |Srt|    Pixel Aspect Ratio     |    7
  1013.                  +---+---------------------------+ 
  1014.  
  1015.                  where:
  1016.  
  1017.                  +------------+-------+---------------------------------+
  1018.                  |    Item    | Data  |           Description           |
  1019.                  |            | Type  |                                 |
  1020.                  +------------+-------+---------------------------------+
  1021.                  |Screen Width|integer|width, in pixels, of the logical |
  1022.                  |            |       |screen                           |
  1023.                  |            |       |                                 |
  1024.                  |            |       |Value:  1 to 65535               |
  1025.                  +------------+-------+---------------------------------+
  1026.                  |Screen      |integer|height, in pixels, of the logical|
  1027.                  |Height      |       |screen                           |
  1028.                  |            |       |                                 |
  1029.                  |            |       |Value:  1 to 65535               |
  1030.                  +------------+-------+---------------------------------+
  1031.                  |Map         |flag   |if set, a Global Color Map Block |
  1032.                  |            |       |follows the Logical Screen       |
  1033.                  |            |       |Descriptor Block; otherwise, an  |
  1034.                  |            |       |Extension Block or an Image      |
  1035.                  |            |       |Descriptor Block follows         |
  1036.                  +------------+-------+---------------------------------+
  1037.  
  1038.                  --------------------------------------------------------
  1039.  
  1040.  
  1041.  
  1042.  
  1043.  
  1044.  
  1045.  
  1046.  
  1047.                                                               (continued)
  1048.  
  1049.  GIF                                                   Revision 1.0, 5/88
  1050.  
  1051.  
  1052.  
  1053.                                       12
  1054.  
  1055.  2.2  Logical Screen Descriptor Block, continued
  1056.  ------------------------------------------------------------------------
  1057.  ------------------------------------------------------------------------
  1058.  
  1059.  Structure of    +------------+-------+---------------------------------+
  1060.  the Logical     |    Item    | Data  |           Description           |
  1061.  Screen          |            | Type  |                                 |
  1062.  Descriptor      +------------+-------+---------------------------------+
  1063.  Block           |Color Res   |field  |defines the number of bits per   |
  1064.  (continued)     |            |       |color component which the GIF    |
  1065.                  |            |       |encoding process had available   |
  1066.                  |            |       |for defining colors in the global|
  1067.                  |            |       |color map; is an indication of   |
  1068.                  |            |       |the richness of the palette from |
  1069.                  |            |       |which colors in the global color |
  1070.                  |            |       |map were chosen                  |
  1071.                  |            |       |                                 |
  1072.                  |            |       |Field value:  0 to 7             |
  1073.                  |            |       |Item value:   1 to 8 bits per    |
  1074.                  |            |       |  red, green, and blue color     |
  1075.                  |            |       |  component                      |
  1076.                  |            |       |                                 |
  1077.                  |            |       |Number of colors in the palette: |
  1078.                  |            |       |   (3 x item value)              |
  1079.                  |            |       |  2                              |
  1080.                  |            |       |  (8 to 16,000,000+)             |
  1081.                  +------------+-------+---------------------------------+
  1082.                  |R1          |n/a    |reserved; must be 0              |
  1083.                  +------------+-------+---------------------------------+
  1084.                  |Pixel Size  |field  |number of bits in each pixel of  |
  1085.                  |            |       |the images in the GIF data;      |
  1086.                  |            |       |determines the number of colors  |
  1087.                  |            |       |defined in the global color map  |
  1088.                  |            |       |(note:  does not indicate the    |
  1089.                  |            |       |number of colors actually used in|
  1090.                  |            |       |an image)                        |
  1091.                  |            |       |                                 |
  1092.                  |            |       |Field value:  0 to 7             |
  1093.                  |            |       |Item value:   1 to 8 bits per    |
  1094.                  |            |       |  pixel                          |
  1095.                  |            |       |                                 |
  1096.                  |            |       |Pixel value:                     |
  1097.                  |            |       |        (item value)             |
  1098.                  |            |       |  0 to 2             - 1         |
  1099.                  |            |       |  (maximum value of 255)         |
  1100.                  |            |       |                                 |
  1101.                  |            |       |Number of colors defined in the  |
  1102.                  |            |       |global color map:                |
  1103.                  |            |       |        (item value)             |
  1104.                  |            |       |  2 to 2                         |
  1105.                  |            |       |  (maximum value of 256)         |
  1106.                  +------------+-------+---------------------------------+
  1107.                  |Background  |byte   |pixel for the screen background  |
  1108.                  |Color Index |       |                                 |
  1109.                  +------------+-------+---------------------------------+
  1110.  
  1111.                  --------------------------------------------------------
  1112.  
  1113.                                                               (continued)
  1114.  
  1115.  GIF                                                   Revision 1.0, 5/88
  1116.  
  1117.  
  1118.  
  1119.                                       13
  1120.  
  1121.  2.2  Logical Screen Descriptor Block, continued
  1122.  ------------------------------------------------------------------------
  1123.  ------------------------------------------------------------------------
  1124.  
  1125.  Structure of    +------------+-------+---------------------------------+
  1126.  the Logical     |    Item    | Data  |           Description           |
  1127.  Screen          |            | Type  |                                 |
  1128.  Descriptor      +------------+-------+---------------------------------+
  1129.  Block           |Srt         |flag   |if set, the global color map is  |
  1130.  (continued)     |            |       |defined in sorted order, most    |
  1131.                  |            |       |used color first; otherwise, no  |
  1132.                  |            |       |assumption may be made about the |
  1133.                  |            |       |order of color definitions in the|
  1134.                  |            |       |global color map                 |
  1135.                  +------------+-------+---------------------------------+
  1136.                  |Pixel Aspect|field  |height to width ratio of each    |
  1137.                  |Ratio       |       |pixel of the source image; if 0  |
  1138.                  |            |       |no aspect ratio is specified     |
  1139.                  |            |       |                                 |
  1140.                  |            |       |Field value:  1 to 127           |
  1141.                  |            |       |Item value:                      |
  1142.                  |            |       |  (field value + 31) / 64        |
  1143.                  |            |       |Item value range:                |
  1144.                  |            |       |  32/64 to 158/64 (0.5 to 2.47)  |
  1145.                  +------------+-------+---------------------------------+
  1146.  
  1147.                  --------------------------------------------------------
  1148.  
  1149.  
  1150.  
  1151.  
  1152.  
  1153.  
  1154.  
  1155.  
  1156.  
  1157.  
  1158.  
  1159.  
  1160.  
  1161.  
  1162.  
  1163.  
  1164.  
  1165.  
  1166.  
  1167.  
  1168.  
  1169.  
  1170.  
  1171.  
  1172.  
  1173.  
  1174.  
  1175.  
  1176.  
  1177.  
  1178.  
  1179.  
  1180.  
  1181.  GIF                                                   Revision 1.0, 5/88
  1182.  
  1183.  
  1184.  
  1185.                                       14
  1186.  
  1187.  2.3  Global Color Map Block
  1188.  ------------------------------------------------------------------------
  1189.  ------------------------------------------------------------------------
  1190.  
  1191.  Overview        The Global Color Map Block contains the global color
  1192.                  map.  The global color map is a series of red, green,
  1193.                  and blue intensity values that defines the individual
  1194.                  colors which may be used in an image.  The global color
  1195.                  map is used for each image in the GIF data unless a
  1196.                  local color map is defined for that image.  
  1197.  
  1198.                  --------------------------------------------------------
  1199.  
  1200.  Existence       The Global Color Map Block is optional.  If present, it
  1201.                  must immediately follow the Logical Screen Descriptor
  1202.                  Block and the MAP flag of the Logical Screen Descriptor
  1203.                  Block must be set.  
  1204.  
  1205.                  --------------------------------------------------------
  1206.  
  1207.  Size            The size, in bytes, of the Global Color Map Block is
  1208.                  three times the number of colors defined within.  The
  1209.                  number of colors defined may range from 2 to 256 and is
  1210.                  determined from the number of bits per pixel:
  1211.  
  1212.                                 (number of bits per pixel)
  1213.                                2
  1214.  
  1215.                  The number of bits per pixel is defined in the PIXEL
  1216.                  SIZE field of the Logical Screen Descriptor Block.
  1217.  
  1218.                  --------------------------------------------------------
  1219.  
  1220.  Structure of    The structure of the Global Color Map Block is
  1221.  the Global      illustrated below.
  1222.  Color Map
  1223.  Block                         Bits
  1224.  
  1225.                    7   6   5   4   3   2   1   0    Byte #
  1226.                  +---+---+---+---+---+---+---+---+
  1227.                  |     Color 0 Red Intensity     |    1
  1228.                  +-------------------------------+
  1229.                  |    Color 0 Green Intensity    |    2
  1230.                  +-------------------------------+
  1231.                  |    Color 0 Blue Intensity     |    3
  1232.                  +-------------------------------+
  1233.                  |     Color 1 Red Intensity     |    4
  1234.                  +-------------------------------+
  1235.                  |    Color 1 Green Intensity    |    5
  1236.                  +-------------------------------+
  1237.                  |    Color 1 Blue Intensity     |    6
  1238.                  +-------------------------------+ 
  1239.                  .                               .  repeat, as needed,
  1240.                  .                               .  for remaining colors
  1241.                  .                               .
  1242.                  +-------------------------------+
  1243.  
  1244.                  --------------------------------------------------------
  1245.                                                               (continued)
  1246.  
  1247.  GIF                                                   Revision 1.0, 5/88
  1248.  
  1249.  
  1250.  
  1251.                                       15
  1252.  
  1253.  2.3  Global Color Map Block, continued
  1254.  ------------------------------------------------------------------------
  1255.  ------------------------------------------------------------------------
  1256.  
  1257.  Structure of    where:
  1258.  the Global
  1259.  Color Map       +------------+-------+---------------------------------+
  1260.  Block           |    Item    | Data  |           Description           |
  1261.  (continued)     |            | Type  |                                 |
  1262.                  +------------+-------+---------------------------------+
  1263.                  |Color n     |byte   |indicates the amount of red      |
  1264.                  |Red         |       |component color n contains       |
  1265.                  |Intensity   |       |                                 |
  1266.                  |            |       |Item value range:  0 (no red)    |
  1267.                  |            |       |  to 255 (maximum red)           |
  1268.                  +------------+-------+------------------------